package cn.itrip.utlis;

import org.joda.time.DateTimeUtils;

import java.text.DateFormat;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @Description :
 * Created by Li on 2020-12-28 15:47:49
 */
public class DateUtils {
    public static Date parse(Date oldDate) {
        Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            //2.进行转化，转化成功直接返回
            return simpleDateFormat.parse(format.format(oldDate));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        //3.如果转化失败返回null
        return null;

//        return format.format(oldDate);
    }

    public static String format(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        return sdf.format(date);
    }
}
